package com.zhang.zhangapp.http;

import android.util.Log;

import com.zhang.zhangapp.base.http.CommonCallBack;
import com.zhang.zhangapp.base.http.MCallback;
import com.zhang.zhangapp.base.http.MHttpParams;

import org.xutils.common.Callback;
import org.xutils.x;

import java.util.Map;


/**
 * Created by Administrator on 2018/3/21.
 */
public class CommonHttp {

    public static Callback.Cancelable commonHttp(String methodPath, Map<String, String> params, MCallback callback) {
        MHttpParams httpParams = new MHttpParams(methodPath);
        if (params != null && params.size() > 0) {
            for (String key : params.keySet()) {
                httpParams.addBodyParameter(key, params.get(key));
            }
        }
        Log.d("reuqestUrl", httpParams.getUri());
        Log.d("postParams", httpParams.getBodyParams().toString());
        return x.http().post(httpParams, new CommonCallBack(callback));
    }
}
